<?php
require_once './model/db.php';
require_once './model/articles.php';

$obj = new articles();
?>

<div id="content">
    <form method="post">
        <table>
            <tr>
            <input type="text" name="title">&nbsp;<input type="submit" value="Search" name="ok">
            </tr>
        </table>
    </form>
    
    <?php  
    if(isset($_POST["ok"]))
{
        if($_POST["title"] == "")
        {
            echo "vui long nhap tu khoa";
        }
        else {
            $key = $_POST["title"];
            $data = $obj ->postsearch($key);

            foreach($data as $value) {?>
        <div class="post">
            <h1 class="title"><a href="<?php echo "index_1.php?view=".$value["id"] ?>"><?php echo $value["title"]; ?></a></h1>
            <p class="meta"><small><?php echo date('d-m-Y', time()); ?><a href="#">  MinhKhoa</a></small></p>
            <div class="entry">
                <?php echo $value["body"]; ?>
            </div>
        </div>
<?php } } }?>
     
</div>
